package com.CST.controller.ys;

import com.CST.common.api.ResultObject;
import com.CST.dto.ys.YsBudgetUpDataDTO;
import com.CST.dto.ys.YsBusinessBudgetDataDTO;
import com.CST.dto.ys.YsManageBudgetDataDTO;
import com.CST.entity.ys.YsManageBudgetData;
import com.CST.service.ys.YsManageBudgetDataService;
import com.CST.vo.ys.YsBudgetDataVO;
import com.CST.vo.ys.YsManageBudgetDataVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author nmx
 * @since 2023-05-24
 */
@Api(tags = "管理预算编制数据")
@RestController
@RequestMapping("/ysManageBudgetData")
public class YsManageBudgetDataController {
    
    private final YsManageBudgetDataService service;

    public YsManageBudgetDataController(YsManageBudgetDataService service) {
        this.service = service;
    }

//    @ApiOperation("分页查询")
//    @PostMapping("/listYsManageBudgetDataPage")
//    public ResultObject<YsBudgetDataVO> listYsManageBudgetDataPage(@RequestBody YsManageBudgetDataDTO dataDTO) {
//        return ResultObject.success(service.listYsManageBudgetDataPage(dataDTO));
//    }

    @ApiOperation("分页查询")
    @PostMapping("/getManageList")
    public ResultObject<PageInfo<YsManageBudgetDataVO>> getManageList(@RequestBody YsManageBudgetDataDTO dto) {
        return ResultObject.success(service.getManageList(dto));
    }

    @ApiOperation("编辑")
    @PostMapping("/updateYsManageBudgetData")
    public ResultObject<Boolean> updateYsManageBudgetData(@RequestBody YsBudgetUpDataDTO dataDTO) {
        return ResultObject.success(service.updateYsManageBudgetData(dataDTO));
    }

    @ApiOperation("导入")
    @PostMapping("/importExcelYsManageBudgetData/{year}")
    public ResultObject<Boolean> importExcelYsManageBudgetData(MultipartFile file,Integer year) {
        return ResultObject.success(service.importExcelYsManageBudgetData(file,year));
    }

    @ApiOperation("导出")
    @PostMapping("/exportExcelYsManageBudgetData")
    public void exportExcelYsManageBudgetData(HttpServletResponse response,@RequestParam Integer year) {
        service.exportExcelYsManageBudgetData(response,year);
    }

    @ApiOperation("导出模板")
    @PostMapping("/exportExcelYsManageBudgetDataDemo")
    public void exportExcelYsManageBudgetDataDemo(HttpServletResponse response) {
        service.exportExcelYsManageBudgetDataDemo(response);
    }
}
